﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;
using GrayParrot.ServiceProcess;

namespace RabbitMQSchedulerService
{
    public partial class SchedulerService : ReliableService<SchedulerService>
    {
        // PUT HERE THE DEFINITION OF YOUR WORKER CODE...
        SchedulerManager m_schedulerManager = null;

        public SchedulerService()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            base.OnStart(args);
        }

        protected override void OnStop()
        {
            base.OnStop();
        }

        protected override void Worker()
        {
            // PUT HERE YOUR WORKER CODE...
            if (m_schedulerManager == null)
            {
                m_schedulerManager = new SchedulerManager();
                m_schedulerManager.Initialize();
            }
        }

        protected override void DisposeWorker()
        {
            // PUT HERE YOUR WORKER CODE DISPOSING...
            if (m_schedulerManager != null)
            {
                m_schedulerManager.Dispose();
                m_schedulerManager = null;
            }
        }
    }
}
